using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class DONVIInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			TENDV,
			DIACHIDV,
			DIENTHOAI,
			FAX,
			MASOTHUE,
			GIAMDOC,
			KTTRUONG,
			TAIKHOAN,
			NGANHANG,
			TINH_TP,
			CHECKSUM
		}
		private Int64 _ID;
		private String _TENDV;
		private String _DIACHIDV;
		private String _DIENTHOAI;
		private String _FAX;
		private String _MASOTHUE;
		private String _GIAMDOC;
		private String _KTTRUONG;
		private String _TAIKHOAN;
		private String _NGANHANG;
		private String _TINH_TP;
		private Double _CHECKSUM;
		
		public Int64 ID{	get{ return _ID;} set{_ID = value;} }
		public String TENDV{	get{ return _TENDV;} set{_TENDV = value;} }
		public String DIACHIDV{	get{ return _DIACHIDV;} set{_DIACHIDV = value;} }
		public String DIENTHOAI{	get{ return _DIENTHOAI;} set{_DIENTHOAI = value;} }
		public String FAX{	get{ return _FAX;} set{_FAX = value;} }
		public String MASOTHUE{	get{ return _MASOTHUE;} set{_MASOTHUE = value;} }
		public String GIAMDOC{	get{ return _GIAMDOC;} set{_GIAMDOC = value;} }
		public String KTTRUONG{	get{ return _KTTRUONG;} set{_KTTRUONG = value;} }
		public String TAIKHOAN{	get{ return _TAIKHOAN;} set{_TAIKHOAN = value;} }
		public String NGANHANG{	get{ return _NGANHANG;} set{_NGANHANG = value;} }
		public String TINH_TP{	get{ return _TINH_TP;} set{_TINH_TP = value;} }
		public Double CHECKSUM{	get{ return _CHECKSUM;} set{_CHECKSUM = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public DONVIInfo()
		{
			_ID = 0;
			_TENDV = "";
			_DIACHIDV = "";
			_DIENTHOAI = "";
			_FAX = "";
			_MASOTHUE = "";
			_GIAMDOC = "";
			_KTTRUONG = "";
			_TAIKHOAN = "";
			_NGANHANG = "";
			_TINH_TP = "";
			_CHECKSUM = 0;
		}
		public DONVIInfo(
		Int64 ID,
		String TENDV,
		String DIACHIDV,
		String DIENTHOAI,
		String FAX,
		String MASOTHUE,
		String GIAMDOC,
		String KTTRUONG,
		String TAIKHOAN,
		String NGANHANG,
		String TINH_TP,
		Double CHECKSUM
		)
		{
			_ID = ID;
			_TENDV = TENDV;
			_DIACHIDV = DIACHIDV;
			_DIENTHOAI = DIENTHOAI;
			_FAX = FAX;
			_MASOTHUE = MASOTHUE;
			_GIAMDOC = GIAMDOC;
			_KTTRUONG = KTTRUONG;
			_TAIKHOAN = TAIKHOAN;
			_NGANHANG = NGANHANG;
			_TINH_TP = TINH_TP;
			_CHECKSUM = CHECKSUM;
		}
		public DONVIInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.ID.ToString()]);
				_TENDV = dr[Field.TENDV.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TENDV.ToString()]);
				_DIACHIDV = dr[Field.DIACHIDV.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DIACHIDV.ToString()]);
				_DIENTHOAI = dr[Field.DIENTHOAI.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DIENTHOAI.ToString()]);
				_FAX = dr[Field.FAX.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.FAX.ToString()]);
				_MASOTHUE = dr[Field.MASOTHUE.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MASOTHUE.ToString()]);
				_GIAMDOC = dr[Field.GIAMDOC.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.GIAMDOC.ToString()]);
				_KTTRUONG = dr[Field.KTTRUONG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.KTTRUONG.ToString()]);
				_TAIKHOAN = dr[Field.TAIKHOAN.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TAIKHOAN.ToString()]);
				_NGANHANG = dr[Field.NGANHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NGANHANG.ToString()]);
				_TINH_TP = dr[Field.TINH_TP.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TINH_TP.ToString()]);
				_CHECKSUM = dr[Field.CHECKSUM.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.CHECKSUM.ToString()]);
			}
		}
		public DONVIInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.ID.ToString()]);
				_TENDV = dr[Field.TENDV.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TENDV.ToString()]);
				_DIACHIDV = dr[Field.DIACHIDV.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DIACHIDV.ToString()]);
				_DIENTHOAI = dr[Field.DIENTHOAI.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DIENTHOAI.ToString()]);
				_FAX = dr[Field.FAX.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.FAX.ToString()]);
				_MASOTHUE = dr[Field.MASOTHUE.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MASOTHUE.ToString()]);
				_GIAMDOC = dr[Field.GIAMDOC.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.GIAMDOC.ToString()]);
				_KTTRUONG = dr[Field.KTTRUONG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.KTTRUONG.ToString()]);
				_TAIKHOAN = dr[Field.TAIKHOAN.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TAIKHOAN.ToString()]);
				_NGANHANG = dr[Field.NGANHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NGANHANG.ToString()]);
				_TINH_TP = dr[Field.TINH_TP.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TINH_TP.ToString()]);
				_CHECKSUM = dr[Field.CHECKSUM.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.CHECKSUM.ToString()]);
			}
		}
		public DONVIInfo(DONVIInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_TENDV = objEntr.TENDV;			
			_DIACHIDV = objEntr.DIACHIDV;			
			_DIENTHOAI = objEntr.DIENTHOAI;			
			_FAX = objEntr.FAX;			
			_MASOTHUE = objEntr.MASOTHUE;			
			_GIAMDOC = objEntr.GIAMDOC;			
			_KTTRUONG = objEntr.KTTRUONG;			
			_TAIKHOAN = objEntr.TAIKHOAN;			
			_NGANHANG = objEntr.NGANHANG;			
			_TINH_TP = objEntr.TINH_TP;			
			_CHECKSUM = objEntr.CHECKSUM;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("DONVI");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int64)),
				new DataColumn(Field.TENDV.ToString(), typeof(String)),
				new DataColumn(Field.DIACHIDV.ToString(), typeof(String)),
				new DataColumn(Field.DIENTHOAI.ToString(), typeof(String)),
				new DataColumn(Field.FAX.ToString(), typeof(String)),
				new DataColumn(Field.MASOTHUE.ToString(), typeof(String)),
				new DataColumn(Field.GIAMDOC.ToString(), typeof(String)),
				new DataColumn(Field.KTTRUONG.ToString(), typeof(String)),
				new DataColumn(Field.TAIKHOAN.ToString(), typeof(String)),
				new DataColumn(Field.NGANHANG.ToString(), typeof(String)),
				new DataColumn(Field.TINH_TP.ToString(), typeof(String)),
				new DataColumn(Field.CHECKSUM.ToString(), typeof(Double))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.TENDV.ToString()] = _TENDV;
			row[Field.DIACHIDV.ToString()] = _DIACHIDV;
			row[Field.DIENTHOAI.ToString()] = _DIENTHOAI;
			row[Field.FAX.ToString()] = _FAX;
			row[Field.MASOTHUE.ToString()] = _MASOTHUE;
			row[Field.GIAMDOC.ToString()] = _GIAMDOC;
			row[Field.KTTRUONG.ToString()] = _KTTRUONG;
			row[Field.TAIKHOAN.ToString()] = _TAIKHOAN;
			row[Field.NGANHANG.ToString()] = _NGANHANG;
			row[Field.TINH_TP.ToString()] = _TINH_TP;
			row[Field.CHECKSUM.ToString()] = _CHECKSUM;
			return row;
		}
        #endregion InitTable
    }
}
